{% extends "base.html" %}
{% load navigation_tags %}
{% load get_config_setting %}
{% block content %}
    {{ block.super }}
    <div class="row">
      <div class="col-md-12">
          <div class="panel panel-default table-responsive">
              <div class="panel-heading">
                  <h4>Credentials
                      <a title="Add New Credential" class="pull-right btn btn-primary btn-sm"
                         href="{% url 'new_cred_product' prod.id %}"><span class="fa-solid fa-plus"></span></a>
                  </h4>
              </div>
              {% if creds %}
                  <table class="tablesorter-bootstrap table table-condensed table-striped table-hover">
                      <thead>
                      <tr>
                        <th>Name</th>
                        <th>Username</th>
                        <th>Role</th>
                        <th>Environment</th>
                        <th>Authentication Provider</th>
                        <th>Login Valid</th>
                        <th>Actions</th>
                      </tr>
                      </thead>
                      <tbody>
                      {% for cred in creds %}
                          <tr>
                            <td>
                                <a href="{{ cred.cred_id.url }}" target="_blank">{{ cred.cred_id.name }}</a>
                            </td>
                            <td>{{ cred.cred_id.username }}</td>
                            <td>{{ cred.cred_id.role }}</td>
                            <td>{{ cred.cred_id.environment }}</td>
                            <td>{{ cred.is_authn_provider }}</td>
                            <td>{{ cred.cred_id.is_valid }}</td>
                            <td>
                                <div class="btn-group">
                                    <a class="btn btn-sm btn-secondary"
                                       href="{% url 'view_cred_product' cred.product.id cred.id  %}">View</a>
                                    <a class="btn btn-sm btn-warning"
                                       href="{% url 'edit_cred_product' cred.product.id cred.id  %}">Edit</a>
                                    <a class="btn btn-sm btn-danger delete-finding"
                                       href="{% url 'delete_cred_product' cred.product.id cred.id  %}">Delete</a>
                                </div>
                            </td>
                          </tr>
                      {% endfor %}
                      </tbody>
                  </table>
              {% else %}
                  <div class="panel-body">
                      <p>No credentials configured.</p>
                  </div>
              {% endif %}
          </div>
      </div>
    </div>
{% endblock %}
